<%@ page import="java.util.List" %>
<%@ page import="com.cc.entity.MeetingRoom" %><%--
  Created by IntelliJ IDEA.
  User: 张余玉珠
  Date: 2025/10/23
  Time: 11:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引入标签库--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>会议室列表</title>
</head>
<style>
    table{
        width: 100%;
    }
    tbody tr:nth-child(even){
        background-color: #f5f5f5;
    }
</style>
<%--引入jquery--%>
<script src="js/jquery.js"></script>
<body>

<h1>会议室列表</h1>
<table border="1">
    <tr>
        <th>编号</th>
        <th>会议室名称</th>
        <th>容纳人数</th>
        <th>会议室部门</th>
        <th>会议室位置</th>
        <th>会议室状态</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${meetingRooms}" var="meetingRoom">
        <tr>
            <td>${meetingRoom.id}</td>
            <td>${meetingRoom.name}</td>
            <td>${meetingRoom.number}</td>
            <td>${meetingRoom.dept}</td>
            <td>${meetingRoom.local}</td>
            <td>
                <c:if test="${meetingRoom.state == 1}">已预约</c:if>
                <c:if test="${meetingRoom.state == 2}">使用中</c:if>
                <c:if test="${meetingRoom.state == 3}">空闲中</c:if>
            </td>
            <td>
                <a href="/meetingRoom.do?action=delete&id=${meetingRoom.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
<%--    <%--%>
<%--        List<MeetingRoom> meetingRooms = (List<MeetingRoom>) request.getAttribute("meetingRooms");--%>
<%--        String status = "";--%>
<%--        for (MeetingRoom meetingRoom : meetingRooms) {--%>
<%--            if(meetingRoom.getState() == 1){--%>
<%--                status="已预约";--%>
<%--            }else if(meetingRoom.getState() == 2){--%>
<%--                status="使用中";--%>
<%--            }else if(meetingRoom.getState() == 3){--%>
<%--                status="空闲中";--%>
<%--            }--%>
<%--    %>--%>
<%--    <tr>--%>
<%--        <td><%= meetingRoom.getId() %></td>--%>
<%--        <td><%= meetingRoom.getName() %></td>--%>
<%--        <td><%= meetingRoom.getNumber() %></td>--%>
<%--        <td><%= meetingRoom.getDept() %></td>--%>
<%--        <td><%= meetingRoom.getLocal() %></td>--%>
<%--        <td><%= status %></td>--%>
<%--        <td>--%>
<%--            <a href="/meetingRoom.do?action=delete&id=<%= meetingRoom.getId() %>">删除</a>--%>
<%--                <%--%>
<%--        }--%>
<%--    %>--%>

</table>
</body>
</html>
<script>
    /*页面加载*/
    // $function(){
    // }
    //js原生加载
    //window.onload = function () {}
    $(document).ready(function (){
        alter("页面加载完成")
        getlist();
    })
    //获取列表
    function getlist(){
        $auth.ajax({
            url:"/meetingRoom.do?action=list",
           type:"post",
            dataType:"json",
            success:function (data) {
                console.log("返回结果集：",data);
            }
        })
    }
</script>
